解决方案

1. 在git内部设置代理

  • 命令行
git config --global http.proxy socks5://127.0.0.1:1080
git config --global https.proxy socks5://127.0.0.1:1080
  • 直接编辑相关文件

C:\Users\用户名文件夹下的 .gitconfig,点击打开。
将以下内容添加进去。

[http]
    proxy = socks5://127.0.0.1:1080
[https]
    proxy = socks5://127.0.0.1:1080

2. 注意下载时是否是https

3. 在使用代理下载时,会遇到git push需要每次输入密码。

通过以下方式解决该问题。

  • 设置记住密码(默认15分钟):
git config --global credential.helper cache
  • 如果想自己设置时间,可以这样做:
git config credential.helper 'cache --timeout=3600'

这样就设置一个小时之后失效

  • 长期存储密码:
git config --global credential.helper store

参考